


clear 
set scheme lean2, permanent
global pm = char(177)
set more off

gl date = c(current_date)
if c(os) == "MacOSX" gl user "/Users/`c(username)'"
else if c(os) == "Windows" gl user "C:\Users\\`c(username)'"
else if c(os) == "Unix" gl user "/usr/`c(username)'"
di "$user

set graphics on  
 
global path_data_processed "\data\processed"
global path_output "\data\output"
 
clear all
set more off

cd "$path_data_processed"
use "experimentRNall.dta", clear

cd "$path_output"
 

 
  set scheme lean2

gen updatingmain = posterior - prior
 gen updatingmain_f = posterior_f - prior

 
 preserve
keep if treatment==0

egen freq1 = group(posterior prior)  
bysort posterior prior  :egen freq_1= count(freq1)

egen freq1_f = group(posterior_f prior)  
bysort posterior_f prior  :egen freq_1_f= count(freq1_f)

tempfile t1
save `t1'
restore

keep if treatment==1
 egen freq2 = group(posterior prior)
 qbys posterior prior: egen freq_2=count(freq2)

egen freq2_f = group(posterior_f prior)  
bysort posterior_f prior  :egen freq_2_f= count(freq2_f) 
 
append using `t1'

 
 qui tw  scatter posterior prior [w=freq_1] if treatment==0, xtitle("Prior Belief") ytitle("Posterior Belief") title("Treatment: 5%", size(medium)) msymbol(smcircle_hollow)  yline(5, lwidth(thick) lc(black) lpattern(dash))
 graph save "scatter_5.gph", replace


 
 
 qui tw  scatter posterior prior [w=freq_2] if treatment==1, xtitle("Prior Belief") ytitle("Posterior Belief") title("Treatment: 35%", size(medium)) msymbol(smcircle_hollow) yline(35, lwidth(thick) lc(black) lpattern(dash))
 graph save "scatter_35.gph", replace

 
  drop if posterior_f==.

 
 qui tw  scatter posterior_f prior [w=freq_1_f] if treatment==0, xtitle("Prior Belief") ytitle("Posterior Belief") title("Treatment: 5% (Follow-up)", size(medium)) msymbol(smcircle_hollow)  yline(5, lwidth(thick) lc(black) lpattern(dash))
 graph save "scatter_followup_5.gph", replace

 
 
 
 qui tw  scatter posterior_f prior [w=freq_2_f] if treatment==1, xtitle("Prior Belief") ytitle("Posterior Belief") title("Treatment: 35% (Follow-up)", size(medium)) msymbol(smcircle_hollow) yline(35, lwidth(thick) lc(black) lpattern(dash))
 graph save "scatter_followup_35.gph", replace

 
 
 

graph combine "scatter_5.gph" "scatter_35.gph" , xcommon ycommon col(2) ///
	name(scatterbeliefupdating, replace)	
	   	 	graph display scatterbeliefupdating, xsize(20) ysize(10) 	 

graph export "scatterbeliefupdating.pdf", replace



graph combine "scatter_followup_5.gph" "scatter_followup_35.gph", xcommon ycommon col(2) ///
	name(scatterbeliefupdatingfollowup, replace)	
	   	 	graph display scatterbeliefupdatingfollowup, xsize(20) ysize(10) 	 
graph export "scatterbeliefupdatingfollowup.pdf", replace




